package vista;
import java.awt.BorderLayout;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;

import javax.swing.WindowConstants;
import javax.swing.SwingUtilities;
import bean.JTextFieldValidator;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class VentanaJuez extends javax.swing.JFrame {
	private JPanel panJuez;
	private JButton btnCancelar;
	private JTextFieldValidator txtNombre;
	private JTextFieldValidator txtCantidadComp;
	private JLabel lblCantidadComp;
	private JButton btnSalir;
	private JButton btnRegistrar;
	private JTextFieldValidator txtFechaNac;
	private JTextFieldValidator txtApellido;
	private JTextFieldValidator txtCedula;
	private JLabel lblFechaNac;
	private JLabel lblApellido;
	private JLabel lblNombre;
	private JLabel lblCedula;

	/**
	* Auto-generated main method to display this JFrame
	*/
		
	public VentanaJuez() {
		super();
		initGUI();
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			BorderLayout thisLayout = new BorderLayout();
			getContentPane().setLayout(thisLayout);
			this.setTitle("Ventana de Jueces");
			{
				panJuez = new JPanel();
				getContentPane().add(panJuez, BorderLayout.CENTER);
				panJuez.setLayout(null);
				{
					lblCedula = new JLabel();
					panJuez.add(lblCedula);
					lblCedula.setText("Cedula:");
					lblCedula.setBounds(58, 49, 98, 15);
				}
				{
					lblNombre = new JLabel();
					panJuez.add(lblNombre);
					lblNombre.setText("Nombre:");
					lblNombre.setBounds(58, 92, 98, 15);
				}
				{
					lblApellido = new JLabel();
					panJuez.add(lblApellido);
					lblApellido.setText("Apellido:");
					lblApellido.setBounds(58, 141, 98, 15);
				}
				{
					lblFechaNac = new JLabel();
					panJuez.add(lblFechaNac);
					lblFechaNac.setText("Fecha de Nacimiento:");
					lblFechaNac.setBounds(58, 182, 170, 15);
				}
				{
					txtCedula = new JTextFieldValidator(8, JTextFieldValidator.SOLO_NUMEROS);
					panJuez.add(txtCedula);
					txtCedula.setBounds(228, 46, 161, 22);
				}
				{
					txtNombre = new JTextFieldValidator(25, JTextFieldValidator.SOLO_LETRAS);
					panJuez.add(txtNombre);
					txtNombre.setBounds(228, 89, 161, 22);
				}
				{
					txtApellido = new JTextFieldValidator(25, JTextFieldValidator.SOLO_LETRAS);
					panJuez.add(txtApellido);
					txtApellido.setBounds(228, 134, 161, 22);
				}
				{
					txtFechaNac = new JTextFieldValidator(10, JTextFieldValidator.NUMERO_Y_SLASH);
					panJuez.add(txtFechaNac);
					txtFechaNac.setBounds(228, 175, 161, 22);
				}
				{
					btnRegistrar = new JButton();
					panJuez.add(btnRegistrar);
					btnRegistrar.setText("Registrar");
					btnRegistrar.setBounds(58, 291, 120, 22);
				}
				{
					btnSalir = new JButton();
					panJuez.add(btnSalir);
					btnSalir.setText("Salir");
					btnSalir.setBounds(368, 291, 75, 22);
				}
				{
					lblCantidadComp = new JLabel();
					panJuez.add(lblCantidadComp);
					lblCantidadComp.setText("Cantidad de Competencias:");
					lblCantidadComp.setBounds(58, 227, 226, 15);
				}
				{
					txtCantidadComp = new JTextFieldValidator(3, JTextFieldValidator.SOLO_NUMEROS);
					panJuez.add(txtCantidadComp);
					txtCantidadComp.setBounds(300, 224, 89, 22);
					txtCantidadComp.setVisible(false);
				}
				{
					btnCancelar = new JButton();
					panJuez.add(btnCancelar);
					btnCancelar.setText("Cancelar");
					btnCancelar.setBounds(195, 291, 111, 22);
				}
			}
			pack();
			this.setSize(538, 371);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}
	
	
	public void agregarListener(ActionListener accion){
	   btnRegistrar.addActionListener(accion);
	   btnSalir.addActionListener(accion);
	   btnCancelar.addActionListener(accion);
	}
	
	public String getCedula(){
		return txtCedula.getText();
	}
	
	public String getNombre(){
		return txtNombre.getText();
	}
	
	public String getApellido(){
		return txtApellido.getText();
	}
	
	public String getFechaNac(){
		return txtFechaNac.getText();
	}
	
	public String getCantidadComp(){
		return txtCantidadComp.getText();
	}
	
	public void setCantidadComp(int cantidad){
		txtCantidadComp.setText(String.valueOf(cantidad));
	}
	
	public void mostrarMensaje(String mensaje){
		JOptionPane.showMessageDialog(this, mensaje);
	}
	
	public void blanquearCampos(){
		txtCedula.setText("");
		txtNombre.setText("");
		txtApellido.setText("");
		txtFechaNac.setText("");
		txtCantidadComp.setText("0");
	}

}
